<template>
  <div class="back-to-top" @click="scrollToTop" v-if="show">
    <image src="../../../static/images/backtop.png" alt="" />
    <text>顶部</text>
  </div>
</template>

<script setup>
const props = defineProps({
  show: {
    type: Boolean,
    required: true,
  },
})

const scrollToTop = () => {
  uni.pageScrollTo({
    scrollTop: 0,
  })
}
</script>

<style scoped lang="scss">
.back-to-top {
  z-index: 999;
  text-align: center;
  position: fixed;
  bottom: 80rpx;
  right: 40rpx;
  width: 96rpx;
  height: 96rpx;
  border-radius: 50%;
  box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3);
  background-color: #ffffff;
  color: #00aabf;
  font-size: 12px;
  padding: 10rpx 22rpx;

  image {
    width: 48rpx;
    height: 48rpx;
  }
}
</style>
